<template>
  <div class="merchant-home">
    <el-card class="welcome-card">
      <div class="welcome-content">
        <div class="welcome-header">
          <el-icon class="welcome-icon"><Shop /></el-icon>
          <h1 class="welcome-title">商家你好！欢迎进入DMS后台系统</h1>
        </div>
        <div class="date-info">
          <el-icon><Calendar /></el-icon>
          <span class="date-text">{{ currentDate }}</span>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { Shop, Calendar } from '@element-plus/icons-vue'

// 格式化日期
const formatDate = (date) => {
  const week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
  const year = date.getFullYear()
  const month = (date.getMonth() + 1).toString().padStart(2, '0')
  const day = date.getDate().toString().padStart(2, '0')
  const weekDay = week[date.getDay()]
  
  return `${year}年${month}月${day}日 ${weekDay}`
}

const currentDate = ref('')

onMounted(() => {
  // 设置初始日期
  currentDate.value = formatDate(new Date())
  
  // 每秒更新一次日期
  setInterval(() => {
    currentDate.value = formatDate(new Date())
  }, 1000)
})
</script>

<style scoped>
.merchant-home {
  padding: 20px;
  min-height: calc(100vh - 120px);
  background-color: #f5f7fa;
}

.welcome-card {
  max-width: 800px;
  margin: 0 auto;
  background: linear-gradient(135deg, #ffffff 0%, #f5f7fa 100%);
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
}

.welcome-content {
  padding: 20px;
  text-align: center;
}

.welcome-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 30px;
}

.welcome-icon {
  font-size: 32px;
  color: var(--el-color-primary);
  margin-right: 12px;
}

.welcome-title {
  font-size: 28px;
  color: #303133;
  margin: 0;
  font-weight: 600;
}

.date-info {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #606266;
}

.date-info .el-icon {
  margin-right: 8px;
  font-size: 20px;
  color: var(--el-color-primary);
}

.date-text {
  font-weight: 500;
}

/* 添加一些动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-card {
  animation: fadeIn 0.8s ease-out;
}
</style>
